/**
 * Created by zhangguanggui on 2017/7/22.
 */
import jsonp from '../common/js/jsonp';
import axios from 'axios';
import {commonParams, options} from './config';

export function getSliderData () {
  const url = 'https://c.y.qq.com/musichall/fcgi-bin/fcg_yqqhomepagerecommend.fcg';
  let paras = Object.assign({}, commonParams, {
    platform: 'h5',
    uin: 0,
    needNewCode: 1
  });
  return jsonp(url, paras, options);
}

export function getDiscList () {
  const url = 'api/getDiscList';
  const para = Object.assign({}, commonParams, {
    platform: 'yqq',
    hostUin: 0,
    sin: 0,
    ein: 29,
    sortId: 5,
    needNewCode: 0,
    categoryId: 10000000,
    rnd: Math.random(),
    format: 'json'
  });
  return axios.get(url, {
    params: para
  }).then(res => {
    return Promise.resolve(res.data);
  }).catch(e => {
    return Promise.reject('getDiscList api error:');
  });
}

export function getSongListFromDisc (disstid) {
  const url = `https://c.y.qq.com/qzone/fcg-bin/fcg_ucc_getcdinfo_byids_cp.fcg`;
  const para = Object.assign({}, commonParams, {
    disstid,
    type: 1,
    json: 1,
    utf8: 1,
    onlysong: '0',
    platform: 'h5',
    hostUin: 0,
    needNewCode: 0
    // type: 1,
    // json: 1,
    // utf8: 1,
    // onlysong: 0,
    // disstid: 2378142101,
    // format: 'jsonp',
    // g_tk: 5381,
    // jsonpCallback: 'jsonpCallback',
    // loginUin: 0,
    // hostUin: 0,
    // inCharset: 'utf8',
    // outCharset: 'utf-8',
    // notice: 0,
    // platform: 'yqq',
    // needNewCode: 0
  });
  return jsonp(url, para, options);
}
